#ifndef SPORT_H
#define SPORT_H
#include "stdint.h"
#include "crc.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "string.h"
#include "stdint.h"
#define SPORT_CONNETED   1
#define SPORT_DISCONNECT 0

#define CROSSFIRE_CH_BITS 			11
#define CROSSFIRE_CENTER 				0x3E0
// Device address
#define BROADCAST_ADDRESS              0x00
#define RADIO_ADDRESS                  0xEA
#define MODULE_ADDRESS                 0xEE

// Frame id
#define GPS_ID                         0x02
#define CF_VARIO_ID                    0x07
#define BATTERY_ID                     0x08
#define BARO_ALT_ID                    0x09
#define LINK_ID                        0x14
#define CHANNELS_ID                    0x16
#define LINK_RX_ID                     0x1C
#define LINK_TX_ID                     0x1D
#define ATTITUDE_ID                    0x1E
#define FLIGHT_MODE_ID                 0x21
#define PING_DEVICES_ID                0x28
#define DEVICE_INFO_ID                 0x29
#define REQUEST_SETTINGS_ID            0x2A
#define COMMAND_ID                     0x32
#define RADIO_ID                       0x3A

#define UART_SYNC                      0xC8
#define SUBCOMMAND_CRSF                0x10
#define COMMAND_MODEL_SELECT_ID        0x05

#define CRSF_MAX_PACKET_LEN 64
void  CRSF_handle_uart_in(void);
void shift_rx_buffer(uint8_t cnt);
void CRSF_handle_byte_received(void);
uint8_t SPORT_get_state(void);
#endif
